package com.ajing.logextractor.filter;


import com.ajing.logextractor.config.FilterConfig;

public class FilterFactory {

    public static AbstractFilter getFilter(FilterConfig filterConfig) {
        if (filterConfig == null) {
            return null;
        }
        if ("JSON".equalsIgnoreCase(filterConfig.getMode())) {
            return new JsonFilter(filterConfig.getPattern(), filterConfig.getMatch());
        } else if ("REGEX".equalsIgnoreCase(filterConfig.getMode())) {
            return new RegexFilter(filterConfig.getPattern(), filterConfig.getMatch());
        } else if ("STRING".equalsIgnoreCase(filterConfig.getMode())) {
            return new StringFilter(filterConfig.getPattern(), filterConfig.getMatch());
        }
        return null;
    }
}
